package com.qdjwz.iceblue;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Luoting on 13-6-3.
 */
public class MyPageAdapter extends PagerAdapter{
    private List<View> viewList;
    private Context context;
    private int mCount;

    public MyPageAdapter(Context context,List<View> viewList){
        this.context = context;
        this.viewList = viewList;
        this.mCount = viewList.size();
    }

    @Override
    public int getCount() {
        return mCount + 1; //此处+1才能向右连续滚动
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view == o;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        if(position >= viewList.size()){
            int newPosition = position % viewList.size();
            position = newPosition;
        }

        if(position < 0){
            position = -position;
        }
    }
}
